package com.example.jiubanben;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    //private Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);



    }
    //旧版对话框
    public void onOldButtonClicked(View view){
        AlertDialog dialog;
        dialog=new AlertDialog.Builder(this).setTitle("旧版本对话框")
                .setMessage("这是旧版本对话框，使用简单\n但是没有支持屏幕翻转!")
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(getApplicationContext(),"你确定了!",Toast.LENGTH_LONG).show();
                    }
                })
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(getApplicationContext(),"你取消了!",Toast.LENGTH_LONG).show();
                    }
                })
                .create();
        dialog.show();


    }


}